package com.authine.cloudpivot.ext.utils;

import com.authine.cloudpivot.ext.dto.model.bill.Bill;
import com.authine.cloudpivot.ext.dto.model.contract.ContractWriteOffRecord;
import com.authine.cloudpivot.ext.dto.model.invoice.InvoiceApply;
import com.authine.cloudpivot.ext.dto.model.invoice.InvoiceDetail;
import com.authine.cloudpivot.ext.dto.model.invoice.InvoiceDetailBill;
import com.authine.cloudpivot.ext.dto.model.settle.Settle;
import com.authine.cloudpivot.ext.dto.model.settle.SettleDetail;
import feign.Contract;

import java.math.BigDecimal;
import java.util.function.BiFunction;

public class BiFunctionConst {



    /**
     * 计算账单总额
     */
    public static final BiFunction<Bill, BigDecimal, BigDecimal> billTotalFun = (billEntity, cumulative) -> BigDecimalUtils.add(billEntity.getTotal(), cumulative);

    /**
     * 计算账单数量
     */
    public final static BiFunction<Bill, BigDecimal, BigDecimal> billQuantityFun = (bill, cumulative) -> bill.getQuantity().add(cumulative);

    /**
     * 计算发票总额
     */
    public final static BiFunction<InvoiceApply, BigDecimal, BigDecimal> invoiceApplyTotalFun = (invoiceApply, cumulative) -> BigDecimalUtils.add(invoiceApply.getTotal(), cumulative);

    /**
     * 计算开票明细对应商品数量
     */
    public final static BiFunction<InvoiceDetail, BigDecimal, BigDecimal> invoiceDetailQuantityFun = (invoiceDetail, cumulative) -> invoiceDetail.getQuantity().add(cumulative);

    /**
     * 明细的价税合计 总和
     */
    public final static BiFunction<InvoiceDetail, BigDecimal, BigDecimal> invoiceDetailTotalFun = (invoiceDetail, cumulative) -> BigDecimalUtils.add(invoiceDetail.getTotal(), cumulative);
    /**
     * 票面明细的价格合计【数量*单价】 总和
     */
    public final static BiFunction<InvoiceDetail, BigDecimal, BigDecimal> invoiceDetailAmountFun = (invoiceDetail, cumulative) -> BigDecimalUtils.add(invoiceDetail.getAmount(), cumulative);

    /**
     * 票面税额 总和
     */
    public final static BiFunction<InvoiceDetail, BigDecimal, BigDecimal> invoiceDetailTaxFun = (invoiceDetail, cumulative) -> BigDecimalUtils.add(invoiceDetail.getTax(), cumulative);

    /**
     * 计算开票明细账单（t_invoice_detail_bill）数量
     */
    public final static BiFunction<InvoiceDetailBill, BigDecimal, BigDecimal> invoiceBillQuantityFun = (invoiceDetail, cumulative) -> invoiceDetail.getQuantity().add(cumulative);

    /**
     * 计算开票明细账单（t_invoice_detail_bill）总额
     */
    public final static BiFunction<InvoiceDetailBill, BigDecimal, BigDecimal> invoiceBillTotalFun = (invoiceDetail, cumulative) -> invoiceDetail.getTotal().add(cumulative);

    /**
     * 计算开票明细账单（t_invoice_detail_bill）已开票总额
     */
    public final static BiFunction<InvoiceDetailBill, BigDecimal, BigDecimal> invoiceProcessBillAlreadyTotalFun = (invoiceDetail, cumulative) -> invoiceDetail.getAlready_total().add(cumulative);


    /**
     * 计算结算单总额
     */
    public static final BiFunction<Settle, BigDecimal, BigDecimal> settleTotalFun = (settle, cumulative) -> BigDecimalUtils.add(settle.getTotal(), cumulative);

    /**
     * 计算结算明细总额
     */
    public static final BiFunction<SettleDetail, BigDecimal, BigDecimal> settleDetailTotalFun = (settleDetail, cumulative) -> BigDecimalUtils.add(settleDetail.getTotal(), cumulative);

    /**
     * 结算明细平台费总额
     */
    public static final BiFunction<SettleDetail, BigDecimal, BigDecimal> settleDetailPlatformFun = (settleDetail, cumulative) -> BigDecimalUtils.add(settleDetail.getPlatform(), cumulative);

    /**
     * 结算明细 垫资服务费总额
     */
    public static final BiFunction<SettleDetail, BigDecimal, BigDecimal> settleDetailInterestFun = (settleDetail, cumulative) -> BigDecimalUtils.add(settleDetail.getInterest(), cumulative);

    /**
     * 代购核销记录总额
     */
    public static final BiFunction<ContractWriteOffRecord, BigDecimal, BigDecimal> contractWriteOffRecordTotalFun = ((contractWriteOffRecord, cumulative) -> BigDecimalUtils.add(contractWriteOffRecord.getWrite_off_amount(),cumulative));
}
